import axios from 'axios';

//创建一个axios示例
const service = axios.create({
  baseURL: 'http://localhost:8000/', // 请求本地的demo后台地址
  timeout: 5000
});

// 请求拦截器
service.interceptors.request.use(
  (config) => {
    return config;
  },
  (error) => {
    console.log('request error=====>' + error);
    Promise.reject(error);
  }
);

// 响应拦截器
service.interceptors.response.use(
  response => {
    return response;
  },
  error => {
    console.log('response error=====>' + error);
    return Promise.reject(error);
  }
);

export default service;
